package com.lagou.controller;

import com.alibaba.fastjson.JSON;
import com.lagou.Vo.DataResult;
import com.lagou.service.Neo4jPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DemoController {

    @Autowired
    Neo4jPersonService neo4jPersonService;

    @RequestMapping("/index")
    public String toLoginPage(Model model){
        return "index";
    }


    @RequestMapping("/demo/findAll")
    @ResponseBody
    public DataResult findAll(@RequestParam("startName")String startName, @RequestParam("endName")String endName){
        boolean isAll=false;
        if("".equals(startName)&&"".equals(endName)){
            isAll=true;
        }
        DataResult result = neo4jPersonService.getAllPersonByStartNameAndName(startName, endName,isAll);
        System.out.println(JSON.toJSON(result));
        return result;
    }


}
